import tkinter as tk
import random


class GuessNumberGame:
    def __init__(self, master):
        self.master = master
        self.master.title("Угадай число")

        self.secret_number = random.randint(1, 128)

        self.label = tk.Label(self.master, text="Введите число от 1 до 128:")
        self.label.pack()

        self.entry = tk.Entry(self.master)
        self.entry.pack()

        self.check_button = tk.Button(self.master, text="Проверить", command=self.check_number)
        self.check_button.pack()

        self.result_text = tk.Text(self.master, height=3, width=30)
        self.result_text.pack()

    def check_number(self):
        guess = int(self.entry.get())

        if guess < self.secret_number:
            result = "Загаданное число больше"
        elif guess > self.secret_number:
            result = "Загаданное число меньше"
        else:
            result = "Вы угадали!"

        self.result_text.delete("1.0", tk.END)
        self.result_text.insert(tk.END, result)


if __name__ == "__main__":
    root = tk.Tk()
    game = GuessNumberGame(root)
    root.mainloop()
